package com.heng.LockSupportDemo;

import java.util.concurrent.TimeUnit;

public class LockSupportDemo1 {
    public static void main(String[] args) {
        Object o = new Object();
        new Thread(() -> {
            synchronized (o){
                System.out.println(Thread.currentThread().getName()+"\t---come in");
                try{
                    o.wait();
                }catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(Thread.currentThread().getName()+"\t---被唤醒");
            }
        },"t1").start();

        try {TimeUnit.MILLISECONDS.sleep(10);}catch (InterruptedException e) {e.printStackTrace();}
        new Thread(() -> {
            synchronized (o) {
                o.notify();
                System.out.println(Thread.currentThread().getName()+"\t---发出通知");
            }
        },"t2").start();
    }
}
